Skip to content

Switch replies to rich text#513

Merged
rob93c merged 10 commits into
mainfrom
reply-with-rich-text
Jun 14, 2026
Merged

Switch replies to rich text#513
rob93c merged 10 commits into
mainfrom
reply-with-rich-text

Conversation

@rob93c

@rob93c rob93c commented Jun 14, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

Release Notes

  • New Features

    • Added a /supported command to display supported file formats in a table.
    • The bot now sends a processing/thinking rich-message while converting files.
    • Improved reply formatting by switching relevant responses to rich messages for clearer styling.
  • Bug Fixes

    • Updated completion responses to send “file ready” as a separate rich-text message (instead of as a document caption).
  • Tests

    • Refreshed assertions and fixtures to validate rich-message payloads, including Markdown/HTML rendering, across the help/privacy/supported and error flows.
  • Chores

    • Expanded test logging to include the test started lifecycle event.

@rob93c rob93c requested a review from MartelliEnrico June 14, 2026 13:22
@rob93c rob93c self-assigned this Jun 14, 2026
@rob93c rob93c added enhancement New feature or request unit test This marks issues revolving around unit tests labels Jun 14, 2026
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f9ffa174-5aad-4d2e-b6e3-d854b0f77522

📥 Commits

Reviewing files that changed from the base of the PR and between 78b26ba and 2dc85b0.

📒 Files selected for processing (1)
  • src/test/java/com/github/stickerifier/stickerify/bot/StickerifyTest.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/java/com/github/stickerifier/stickerify/bot/StickerifyTest.java

📝 Walkthrough

Walkthrough

The bot's text-response mechanism is migrated from SendMessage/MarkdownV2 to SendRichMessage/InputRichMessage.markdown. A PROCESSING draft message is now sent before file conversion begins. The Answer enum drops the disableLinkPreview API and gains PROCESSING and SUPPORTED_FORMATS constants. A new /supported command is wired into TelegramRequest. Tests are updated throughout to assert against sendRichMessage JSON payloads.

Changes

Rich-message migration and /supported command

Layer / File(s) Summary
Answer enum: contract simplification and new constants
src/main/java/com/github/stickerifier/stickerify/telegram/Answer.java
Removes disableLinkPreview field, constructor, and isDisableLinkPreview() method; reformats message text blocks using text blocks; adds PROCESSING and SUPPORTED_FORMATS enum constants.
/supported command wiring
src/main/java/com/github/stickerifier/stickerify/telegram/model/TelegramRequest.java
Adds SUPPORTED_COMMAND constant and maps it to SUPPORTED_FORMATS in getAnswerMessage(), enabling the bot to respond to /supported.
Stickerify bot: SendRichMessage and processing draft
src/main/java/com/github/stickerifier/stickerify/bot/Stickerify.java
Updates imports for rich-message types, introduces PROCESSING_MESSAGE draft constant, sends a SendRichMessageDraft before file conversion, removes FILE_READY caption from document send, and replaces SendMessage/MarkdownV2 in answerText with SendRichMessage/InputRichMessage.markdown.
Test infrastructure: mock responses and assertion helpers
src/test/java/com/github/stickerifier/stickerify/bot/MockResponses.java, src/test/java/com/github/stickerifier/stickerify/bot/StickerifyTest.java
Renames EMPTY_UPDATES to SUCCESS_RESPONSE, adds SUPPORTED_MESSAGE mock fixture, switches URL encoding/decoding to extract rich_message parameter, and refactors assertResponseContainsMessage to parse rich_message JSON with a messageFormat parameter selector.
Test case updates for rich-message and /supported
src/test/java/com/github/stickerifier/stickerify/bot/StickerifyTest.java
Updates all test assertions to use /api/token/sendRichMessage endpoint, validates Markdown payloads for text responses, asserts sendRichMessageDraft HTML content for processing drafts, and covers the new /supported command.
Build: test logging
build.gradle
Adds started to testLogging events alongside passed, failed, and skipped.

Sequence Diagram(s)

sequenceDiagram
  participant Client as Telegram Client
  participant Stickerify as Stickerify Bot
  participant TelegramAPI as Telegram API

  rect rgba(173, 216, 230, 0.5)
    Note over Client, TelegramAPI: Text command (e.g. /start, /help, /supported)
    Client->>Stickerify: Command message
    Stickerify->>TelegramAPI: sendRichMessage(InputRichMessage.markdown(answer.getText()))
  end

  rect rgba(144, 238, 144, 0.5)
    Note over Client, TelegramAPI: File processing
    Client->>Stickerify: File upload
    Stickerify->>TelegramAPI: sendRichMessageDraft(PROCESSING_MESSAGE)
    Stickerify->>TelegramAPI: sendDocument(converted file)
    Stickerify->>TelegramAPI: sendRichMessage(InputRichMessage.markdown(FILE_READY.getText()))
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Stickerifier/Stickerify#403: Modifies the same StickerifyTest and MockResponses test infrastructure, including mock update constants and dispatcher configuration.
  • Stickerifier/Stickerify#489: Alters src/main/java/com/github/stickerifier/stickerify/bot/Stickerify.java in the core Telegram request handling and reply flow path.
  • Stickerifier/Stickerify#257: Touches Stickerify.java's file download/conversion flow where rich "processing" messaging is now added around the conversion sequence.

Suggested reviewers

  • MartelliEnrico

Poem

🐇 Hoppity hop, no plain text today,
Rich messages now hop along the way!
A /supported command joins the warren,
Draft "Processing…" notes — nothing's borin'.
The enum sheds its preview disguise,
And tests now parse JSON with bright eyes! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Switch replies to rich text' directly and accurately describes the main objective of the pull request, which involves migrating from plain-text and MarkdownV2 messaging to rich-message APIs across the Telegram bot.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/com/github/stickerifier/stickerify/telegram/model/TelegramRequest.java (1)

83-88: ⚠️ Potential issue | 🟠 Major

Normalise bot commands by stripping the optional @username suffix before switching on message.text().

Telegram bot commands in group chats are sent with the bot's username appended (e.g. /start@MyBot_bot). The current implementation uses exact string matching, which will fail to recognise these commands and fall through to the default case, returning ABOUT instead of the correct answer. This affects both getAnswerMessage() and isNewUser(). Extract the command portion before the @ symbol or use a helper method to normalise the text before the switch.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/github/stickerifier/stickerify/telegram/model/TelegramRequest.java`
around lines 83 - 88, The switch statement in the getAnswerMessage() method (and
similarly in isNewUser()) operates directly on message.text() without
normalizing bot commands. Telegram bot commands in group chats include the
optional `@username` suffix (e.g., /start@MyBot_bot), so exact string matching
will fail to recognize these commands and fall through to the default case.
Create a helper method that extracts the command portion before the @ symbol (or
returns the full text if no @ is present), then use this normalized text in the
switch statement in both getAnswerMessage() and isNewUser() methods.
🧹 Nitpick comments (1)
src/main/java/com/github/stickerifier/stickerify/telegram/Answer.java (1)

47-69: ⚡ Quick win

Keep the rich-text format in the enum contract.

PROCESSING is HTML, while the other answers are markdown, but Answer now only exposes raw text. Downstream code already has to special-case Answer.PROCESSING in src/test/java/com/github/stickerifier/stickerify/bot/StickerifyTest.java Lines 64-66, so the contract is now split across files. Please add a RichMessageFormat/MessageFormat field to the enum and let callers read it instead of branching on specific enum values.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/com/github/stickerifier/stickerify/telegram/Answer.java` around
lines 47 - 69, The Answer enum currently mixes HTML and markdown formats without
exposing this information, forcing downstream code to special-case the
PROCESSING enum value. Add a RichMessageFormat (or MessageFormat) field to the
Answer enum to track whether each answer is HTML or markdown. Update each enum
constant (PROCESSING, SUPPORTED_FORMATS, and any others) to specify their
respective format, modify the Answer constructor to accept this format
parameter, and add a getter method (like getFormat()) to expose it. This allows
callers to check the format via the enum field instead of branching on specific
enum values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/com/github/stickerifier/stickerify/bot/Stickerify.java`:
- Around line 151-152: The order of operations in the file upload workflow is
incorrect. Currently, the FILE_READY message is sent via answerText before the
actual document upload via execute(answerWithFile), which means users could
receive a success notification even if the file upload fails. Reverse the order
of these two calls: execute the document send operation first using
answerWithFile, and then send the FILE_READY message via answerText only after
the upload completes successfully.

In `@src/main/java/com/github/stickerifier/stickerify/telegram/Answer.java`:
- Around line 50-59: The SUPPORTED_FORMATS constant now advertises support for
animated stickers alongside static and video stickers, but the HELP and ERROR
response constants still only reference standard and video sticker support.
Update both the HELP and ERROR message constants in the Answer class to include
animated stickers in their descriptions of supported sticker types, ensuring all
user-facing messages provide consistent guidance about the three supported
sticker formats.

---

Outside diff comments:
In
`@src/main/java/com/github/stickerifier/stickerify/telegram/model/TelegramRequest.java`:
- Around line 83-88: The switch statement in the getAnswerMessage() method (and
similarly in isNewUser()) operates directly on message.text() without
normalizing bot commands. Telegram bot commands in group chats include the
optional `@username` suffix (e.g., /start@MyBot_bot), so exact string matching
will fail to recognize these commands and fall through to the default case.
Create a helper method that extracts the command portion before the @ symbol (or
returns the full text if no @ is present), then use this normalized text in the
switch statement in both getAnswerMessage() and isNewUser() methods.

---

Nitpick comments:
In `@src/main/java/com/github/stickerifier/stickerify/telegram/Answer.java`:
- Around line 47-69: The Answer enum currently mixes HTML and markdown formats
without exposing this information, forcing downstream code to special-case the
PROCESSING enum value. Add a RichMessageFormat (or MessageFormat) field to the
Answer enum to track whether each answer is HTML or markdown. Update each enum
constant (PROCESSING, SUPPORTED_FORMATS, and any others) to specify their
respective format, modify the Answer constructor to accept this format
parameter, and add a getter method (like getFormat()) to expose it. This allows
callers to check the format via the enum field instead of branching on specific
enum values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5dcbf90b-4066-47e4-b60c-262f0f8fb91e

📥 Commits

Reviewing files that changed from the base of the PR and between f07ad20 and 23663dd.

📒 Files selected for processing (6)
  • build.gradle
  • src/main/java/com/github/stickerifier/stickerify/bot/Stickerify.java
  • src/main/java/com/github/stickerifier/stickerify/telegram/Answer.java
  • src/main/java/com/github/stickerifier/stickerify/telegram/model/TelegramRequest.java
  • src/test/java/com/github/stickerifier/stickerify/bot/MockResponses.java
  • src/test/java/com/github/stickerifier/stickerify/bot/StickerifyTest.java

Comment thread src/main/java/com/github/stickerifier/stickerify/bot/Stickerify.java Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 14, 2026
@rob93c rob93c merged commit efb7db7 into main Jun 14, 2026
10 of 12 checks passed
@rob93c rob93c deleted the reply-with-rich-text branch June 14, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request unit test This marks issues revolving around unit tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants